<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License

Name       : Breakeven 
Description: A two-column, fixed-width design with dark color scheme.
Version    : 1.0
Released   : 20130509
-->

<?php
	session_start();  
	if (!isset($_SESSION['login'])) { 
	   header ('Location: ../index.html'); 
	   exit();  
	} 
	else
	{
		$base = mysql_connect ('localhost', 'root', 'master'); 
		mysql_select_db ('easyimmo', $base); 
	} 
?>



<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>EASY-Immo</title>
	
	<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600" rel="stylesheet" type="text/css" />
	<link href='http://fonts.googleapis.com/css?family=Abel|Satisfy' rel='stylesheet' type='text/css'>
	<link href="../style.css" rel="stylesheet" type="text/css" media="screen" />
	<link rel="stylesheet" href="style-tableau.css" />
	
	<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
	<script type='text/javascript' src='../menu_jquery.js'></script>

	
	<script type='text/javascript'>
		function ActionSelect(Objet){
			
			var val = Objet.value.toUpperCase();
			var res = val.split(":"); 
			
			var action = res[0];
			var itemID = res[1];
			
			var module = "TypePieces";
			var rel1 = "CONTRATS";
			var rel2 = "LOGEMENTS";
			var rel3 = "DOCUMENTS";
			var rel4 = "VERSEMENTS";	
			
			var dest;
			switch(action){
				case "EDIT" :
					dest= "edit" + module + ".php?item="+ itemID;
					break;
				case "DELETE" :
					dest= "delete" + module + ".php?item="+ itemID;
					break;
				case "VIEW" :
					dest= "view" + module + ".php?item="+ itemID;
					break;
				case rel1 :
					dest= rel1.toLowerCase() + ".php?item="+ itemID ;
					break;
				case rel2 :
					dest= rel2.toLowerCase() + ".php?item="+ itemID;
					break;
				case rel3 :
					dest= rel3.toLowerCase() + ".php?item="+ itemID;
					break;
				case rel4 :
					dest= rel4.toLowerCase() + ".php?item="+ itemID;
					break;					
				default:
					return false;
			}
			
			window.location = dest;
		}
	</script>	
</head>
	<body>
		<div id="wrapper">
			<!-- ==================================== HEADER ================================================== -->
			<div id="header-wrapper">
				<div id="header" class="container">
					<div id="logo">
						<h1><a href="index.html"><strong>EASY-Immo</strong></a></h1>
					</div>
					<div id="menu">
						<ul>
							<li class="current_page_item"><a href="membre.php">Bureau</a></li>
							<li><a href="administration.php">Administration</a></li>
							<li><a href="../deconnexion.php">Deconnexion</a></li>
						</ul>
					</div>
				</div>
			</div>
			<!-- end #header -->
			<!-- ============================================================================================= -->

			<div id="page">
				<h3>Bienvenue <?php echo " ".htmlentities(trim($_SESSION['nom']))." ".htmlentities(trim($_SESSION['prenom'])); ?>!</h3><br />
				Vous ête ici : <a href="membre.php">Données de réferences</a> / <a href="pieces.php">Types de pièces</a>
				
				<br><br><br>
				
				<?php 
					if (isset($_GET['item'])) 
					{ 
						$sql = 'SELECT * FROM type_piece WHERE id_type_piece ='.$_GET['item']; 
						echo "<h3> Details type de pieces Nr : ".$_GET['item']."</h3>";
					}
					else
					{
					
						$sql = "SELECT * FROM type_piece";	 	
					}
					$req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error()); 
					$num_rows = mysql_num_rows($req);
				?>
				<br><br>
				
				<table>
					<tr>
						<td valign="top">
							<div id='cssmenu'>
								<ul>
								   <li><span></span></li>
								   <li class='has-sub'><a href='#'><span>Données de réferences</span></a>
									  <ul>
										 <li><a href='pieces.php'><span>Types de pièces</span></a></li>
										 <li><a href='#'><span>Types de documents</span></a></li>
										 <li><a href='#'><span>Types de comptes</span></a></li>
										 <li><a href='#'><span>Types de travaux</span></a></li>
										 <li><a href='#'><span>Parcelles</span></a></li>
										 <li><a href='#'><span>Contrats</span></a></li>
										 <li class='last'><a href='#'><span>Logements</span></a></li>
									  </ul>
								   </li>
								   <li class='has-sub'><a href='#'><span>Locataires</span></a>
									  <ul>
											<li><a href='#'><span>Nouveau locataire</span></a></li>
											<li class='last'><a href='#'><span>Afficher les locataires</span></a></li>
									  </ul>
								   </li>
								   <li class='has-sub'><a href='#'><span>Documents</span></a>								  
										<ul>
											<li><a href='#'><span>Afficher les documents</span></a></li>
											<li><a href='#'><span>Scanner un document</span></a></li>
											<li><a href='#'><span>Afficher les quittances</span></a></li>
											<li><a href='#'><span>Enregistrer une facture</span></a></li>
											<li><a href='#'><span>Créer une quittance</span></a></li>
											<li class='last'><a href='#'><span>Imprimer un document</span></a></li>
										</ul>
								   </li>
								   <li class='has-sub'><a href='#'><span>Maintenance</span></a>
									  <ul>
											<li><a href='#'><span>Afficher les maintenances</span></a></li>
											<li><a href='#'><span>Consulter les états des lieux</span></a></li>
											<li class='last'><a href='#'><span>Planifier des travaux</span></a></li>
									  </ul>
								   </li>
								   <li class='has-sub'><a href='#'><span>Finance</span></a>
									  <ul>
											<li><a href='#'><span>Suivi budget</span></a></li>								  
											<li><a href='#'><span>Budgetisation</span></a></li>
											<li><a href='#'><span>Consommation energetique</span></a></li>
											<li><a href='#'><span>Mouvement ponctuel</span></a></li>
											<li><a href='#'><span>Planifier un mouvement</span></a></li>
											<li class='last'><a href='#'><span>Générer le bilan</span></a></li>
									  </ul>							   
								   </li>							   
								   <li class='has-sub'><a href='#'><span>Comptabilité</span></a>
									  <ul>
											<li><a href='#'><span>Créer un compte</span></a></li>									  
											<li><a href='#'><span>Consulter les comptes</span></a></li>
											<li><a href='#'><span>Consulter les cautions</span></a></li>
											<li><a href='#'><span>Afficher les versements</span></a></li>
											<li><a href='#'><span>Suivre les versements</span></a></li>
											<li><a href='#'><span>Enregistrer un versement</span></a></li>
											<li><a href='#'><span>Enregistrer une dépense</span></a></li>
											<li><a href='#'><span>Déclaration fiscale</span></a></li>
											<li class='last'><a href='#'><span>Planifier des versements</span></a></li>
									  </ul>							   
								   </li>
								   <li class='has-sub'><a href='#'><span>Sécurité</span></a>
									  <ul>
										 <li><a href='#'><span>Droits</span></a></li>
										 <li><a href='#'><span>Roles</span></a></li>
										 <li><a href='#'><span>Profils</span></a></li>
										 <li class='last'><a href='#'><span>Utilisateurs</span></a></li>
									  </ul>
								   </li>
								   <li class='has-sub'><a href='#'><span>Rechercher</span></a>
									  <ul>
										 <li><a href='#'><span>Rechercher un compte</span></a></li>
										 <li><a href='#'><span>Rechercher un contrat</span></a></li>
										 <li><a href='#'><span>Rechercher un versement</span></a></li>
										 <li><a href='#'><span>Rechercher un document</span></a></li>
										 <li class='last'><a href='#'><span>Rechercher un locataire</span></a></li>
									  </ul>
								   </li>
								   <li class='has-sub'><a href='#'><span>Rapport</span></a>
									  <ul>
										 <li><a href='#'><span>Consulter le journal</span></a></li>
										 <li><a href='#'><span>Consommation Eau</span></a></li>
										 <li><a href='#'><span>Consommation Electricité</span></a></li>
										 <li class='last'><a href='#'><span>Exporter un rapport</span></a></li>
									  </ul>
								   </li>
								   <li class='has-sub'><a href='#'><span>Alertes</span></a>
									  <ul>
										 <li><a href='#'><span>Afficher les alertes</span></a></li>
										 <li class='last'><a href='#'><span>Créer une alerte</span></a></li>
									  </ul>	
								   </li>
								   <li class='last'><span></span></li>
								</ul>
							</div>										
						</td>
						<td width="1000" align="right" valign="top">
							<div align="left">
								<table border="0" width="750" style="margin:0 auto 15px">
									<tr>
										<td>
											<input class="btn" type="button" onclick="window.location='addTypePieces.php';" value="Ajouter"/>
											
											<?php
												//Afficher le boutton si on trouve des enregistrements
												if($num_rows > 0)
												{
													echo "<input class=\"btn\" type=\"button\" onclick= \"window.location='membre.php';\" value=\"Supprimer la selection\"/>";
												}
											?>
											
										</td>
									</tr>
								</table>
							</div >
								
							<div>
								<table cellpadding="0" cellspacing="0" border="0" id="table" class="sortable">
									<thead>
										<tr bgcolor="#A50810">
											<th width="10"><h3>#</h3></font></th>
											<th><h3>ID</h3></font></th>
											<th><h3>Nom</h3></font></th>
											<th><h3>Action</h3></th>
										</tr>
									</thead>
									<tbody>
										<?php
											if($num_rows==0)
											{
												echo "<tr align=\"center\"><td colspan=\"10\">Aucun enregistrement trouvé</td></tr>";
											}
											else
											{
												for($i=0; $i<$num_rows; $i++)
												{
													$row = mysql_fetch_array($req, MYSQL_ASSOC);

													echo "<tr align=\"left\">";
													echo '  <td><input name="msg[]" type="checkbox" id="msg[]" value="'.$row['id_type_piece'].'"></td>'; 
													echo "	<td>".$row['id_type_piece']."</td>";
													echo "	<td>".$row['nom']."</td>";
													echo "	<td>";
													echo "		<FORM METHOD=\"GET\" name=\"action\">";
													echo "			<SELECT NAME=\"cond2\" SIZE=1 onchange=\"ActionSelect(this)\">";
													echo "				<OPTION  VALUE=\"view:".$row['id_type_piece']."\">Choisir une action...</OPTION>";
													echo "				<OPTION  VALUE=\"view:".$row['id_type_piece']."\">Afficher</OPTION>";
													echo "				<OPTION  VALUE=\"edit:".$row['id_type_piece']."\">Modifier</OPTION>";
													echo "				<OPTION  VALUE=\"delete:".$row['id_type_piece']."\">Supprimer</OPTION>";
													echo "				<OPTION  VALUE=\"logements:".$row['id_type_piece']."\">Voir les logements</OPTION>";
													echo "				<OPTION  VALUE=\"contrats:".$row['id_type_piece']."\">Voir les contrats</OPTION>";
													echo "				<OPTION  VALUE=\"versements:".$row['id_type_piece']."\">Voir les versements</OPTION>";
													echo "				<OPTION  VALUE=\"documents:".$row['id_type_piece']."\">Voir les documents</OPTION>";
													echo "			</SELECT>";
													echo "		</FORM>";										
													echo "	</td>";
													echo "</tr>";

												}
												/*
												<?php
													if(!empty($_POST['msg']))  
													{  
														mysql_query('DELETE FROM message WHERE code IN('.implode(',',$_POST['msg']).')');  
													}  
												?> 
												*/
												
												mysql_free_result ($req);  
												mysql_close (); 
											}
										?>
									</tbody>
								</table>
								
								<?php
									//Afficher le boutton si on trouve des enregistrements
									if($num_rows > 0)
									{
										echo "<div id=\"controls\">";
										echo "	<div id=\"perpage\">";
										echo "		<select onchange=\"sorter.size(this.value)\">";
										echo "		<option value=\"5\">5</option>";
										echo "			<option value=\"10\" selected=\"selected\">10</option>";
										echo "			<option value=\"20\">20</option>";
										echo "			<option value=\"50\">50</option>";
										echo "			<option value=\"100\">100</option>";
										echo "		</select>";
										echo "		<span>Nombre de ligne par page</span>";
										echo "	</div>";
										echo "	<div id=\"navigation\">";
										echo "		<img src=\"images/first.gif\" width=\"16\" height=\"16\" alt=\"First Page\" onclick=\"sorter.move(-1,true)\" />";
										echo "		<img src=\"images/previous.gif\" width=\"16\" height=\"16\" alt=\"First Page\" onclick=\"sorter.move(-1)\" />";
										echo "		<img src=\"images/next.gif\" width=\"16\" height=\"16\" alt=\"First Page\" onclick=\"sorter.move(1)\" />";
										echo "		<img src=\"images/last.gif\" width=\"16\" height=\"16\" alt=\"Last Page\" onclick=\"sorter.move(1,true)\" />";
										echo "	</div>";
										echo "	<div id=\"text\">Affichage Page <span id=\"currentpage\"></span> sur <span id=\"pagelimit\"></span></div>";
										echo "</div>";										
									}
								?>
								
								<script type="text/javascript" src="script.js"></script>
								<script type="text/javascript">
									var sorter = new TINY.table.sorter("sorter");
									sorter.head = "head";
									sorter.asc = "asc";
									sorter.desc = "desc";
									sorter.even = "evenrow";
									sorter.odd = "oddrow";
									sorter.evensel = "evenselected";
									sorter.oddsel = "oddselected";
									sorter.paginate = true;
									sorter.currentid = "currentpage";
									sorter.limitid = "pagelimit";
									sorter.init("table",1);
								</script>
							</div>									
						</td>
					</tr>
				</table>
				<div style="clear: both; float: none; height: 0;"></div>		
				<!-- end #content -->			
			</div>
			<!-- end #page --> 
		</div>
		<br><br><br><br><br><br><br><br><br>
		<div id="footer">
			<p>Copyright (c) 2013 easy-immo.com. All rights reserved.</p>
		</div>
		<!-- end #footer -->
	</body>
</html>
